//
//  HourseDetailCell.m
//  WGFGlobalHouses
//
//  Created by welldone on 15/5/8.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "HourseDetailCell.h"
#import "NSString+StringHight.h"


@interface HourseDetailCell ()

@property (weak, nonatomic) IBOutlet UILabel *detailLab;

@end


@implementation HourseDetailCell
@synthesize detailLab;



+(instancetype) cellWithTableView:(UITableView *)tableview;
{
    static NSString *ID = @"HourseDetailCell";
    HourseDetailCell *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HourseDetailCell" owner:nil options:nil]lastObject];
        
        [cell.detailLab setPreferredMaxLayoutWidth:[UIScreen mainScreen].bounds.size.width-20];
    }
    
    return cell;
}

+(CGFloat)getHight:(NearbyCellData *)data withTableView:(UITableView *)tableView{
    
    static HourseDetailCell *cell = nil;
    
    static dispatch_once_t predicate;
    
    dispatch_once(&predicate, ^{
        
        cell = [HourseDetailCell cellWithTableView:tableView];
        
    });
    
    [cell setData:data];
    
    CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    
    return height+1;
}




-(void)setData:(NearbyCellData*)data{
    
    NSMutableString *poingStr = [NSMutableString stringWithString:data.detail];
    if (data.detail.length>80) {
        poingStr = [[NSMutableString alloc]initWithString:[data.detail substringToIndex:80]];
        [poingStr appendString:@"......."];
    }
    
    [self.detailLab setAttributedText:[poingStr attributedStringFromStingWithFont:self.detailLab.font withLineSpacing:3]];
    
    [self.detailLab layoutIfNeeded];
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
